const mysql = require("mysql")
class CreateQuery {
    constructor() {
        this.db = null
    }
    // 初始化仓库
    init_database() {
        this.db = mysql.createConnection({
            host: 'localhost',
            user: 'root',
            password: 'mysql',
            database: 'dataall',

        })
        this.db.connect()
    }
    select(sql, params) {
        return new Promise((resolve, reject) => {
            this.db.query(sql, params, function (error, result, fileds) {
                if (error) reject(error)
                resolve(result)
            })
        })
    }
    destory() {
        this.db.end()
    }
}
module.exports = CreateQuery
